package com.tlkg.qa.redistest;

import java.util.concurrent.atomic.AtomicInteger;

import com.tlkg.qa.redistest.self.newer.RedisUtil;

import lombok.extern.log4j.Log4j;

@Log4j
public class TestThead extends Thread {

	/**
	 * 1 -- set <br/>
	 * 2 -- get
	 */
	private int test = 1;

	public TestThead(String name) {
		this.setName(name);
	}

	public void run() {
		// count.getAndAdd(1);
		if (test == 1) {
			log.debug(this.getName() + " start - set");
			String set = RedisUtil.set(this.getName(), "test_" + this.getName());
			if (!"OK".equals(set)) {
				Count.setmisscount.getAndAdd(1);
			}
			log.debug(this.getName() + " end - set" + set);
		}

		if (test == 2) {
			log.debug(this.getName() + " start - get");
			String get = RedisUtil.get(this.getName());
			if (null == get) {
				Count.getmisscount.getAndAdd(1);
			}
			log.debug(this.getName() + " end - get " + get);
		}
		// System.out.printf("%d\n", count.get());

	}

	public void setTest(int test) {
		this.test = test;
	}
}
